//
//  AppDelegate+QSUMShare.m
//  ZengLongSeSha
//
//  Created by apple on 2017/7/12.
//  Copyright © 2017年 Song. All rights reserved.
//

#import "AppDelegate+QSUMShare.h"
#import <UMSocialCore/UMSocialCore.h>

@implementation AppDelegate (QSUMShare)
- (void)UMShareApplication:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // 打开日志
    [[UMSocialManager defaultManager] openLog:YES];
    [UMSocialGlobal shareInstance].isClearCacheWhenGetUserInfo = NO;
    
    // 设置友盟appkey
    [[UMSocialManager defaultManager] setUmSocialAppkey:kUMShareAppKey];
    
    // 配置分享的平台
    [self configUSharePlatforms];
}

/**
 *  配置分享的平台
 */
- (void)configUSharePlatforms
{
    // 微信
    [[UMSocialManager defaultManager] setPlaform:UMSocialPlatformType_WechatSession appKey:kWeChatAppKey appSecret:kWeChatAppSecret redirectURL:nil];
    
    // QQ
    [[UMSocialManager defaultManager] setPlaform:UMSocialPlatformType_QQ appKey:kQQAppKey  appSecret:nil redirectURL:nil];
    
    // 新浪微博
    [[UMSocialManager defaultManager] setPlaform:UMSocialPlatformType_Sina appKey:kSinaAppKey  appSecret:kSinaAppSecret redirectURL:kSinaRedirectURL];
}

// 支持所有iOS系统
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
    BOOL result = [[UMSocialManager defaultManager] handleOpenURL:url sourceApplication:sourceApplication annotation:annotation];
    if (!result) {
        // 其他如支付等SDK的回调
    }
    return result;
}
@end
